#ifndef COMMONPAGE_H
#define COMMONPAGE_H

#include <QWidget>
#include <QListWidgetItem>
#include "musiclist.h"
#include "qmediaplaylist.h"

namespace Ui {
class CommonPage;
}

enum PageType
{
    LIKE_PAGE,
    LOCAL_PAGE,
    RECENT_PAGE,
    SEARCH_PAGE
};

class CommonPage : public QWidget
{
    Q_OBJECT

public:
    explicit CommonPage(QWidget *parent = nullptr);
    ~CommonPage();

    void setCommonPageUi(const QString& pageTitle, const QString& imagePath);

    void setMusicListType(const PageType&);

    void addMusicToCommonPage(MusicList&);

    void refresh(MusicList&);

    //将歌曲添加到播放列表中
    void addMusicToPlaylist(MusicList& musicList, QMediaPlaylist* playlist);

    const QString& getMusicByIndex(int);

    void updateMusicCover(QVariant);

    void initSearchPage();
signals:
    void updateLikeMusic(bool, const QString);

    void playAll(PageType);

    void playMusicByIndex(CommonPage*, int);

private:
    Ui::CommonPage *ui;

    PageType pageType;
    QVector<QString> musicOfPage;
    QSet<QListWidgetItem*> items;
};

#endif // COMMONPAGE_H
